﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Imaginecup.sprite;
using Imaginecup.util.resourceMan;
using imaginecup.util;
using Imaginecup.sprite.animation;
using Microsoft.Xna.Framework;

namespace Imaginecup.gameState.water.mapMan
{
    public class MapMan
    {
        Dictionary<string, IBackGround> m_ObjectDictionary;
//        AnimationIndexMan indexMan = new AnimationIndexMan();
        public MapMan()
        {
            m_ObjectDictionary = new Dictionary<string, IBackGround>();
            InitMapObject();
        }
        public void InitMapObject()
        {
            IBackGround baseBackground = new BackgroundBase();
            IBackGround waveBackground = new BackgroundWave();
            m_ObjectDictionary.Add("BaseBackground", baseBackground);
            m_ObjectDictionary.Add("WaveBackground", waveBackground);
        }
        
        public void Release()
        {
            m_ObjectDictionary.Clear();
        }

        public void SetDirection(Point direction)
        {
            foreach (KeyValuePair<String, IBackGround> backGround_Pair in m_ObjectDictionary)
            {
                backGround_Pair.Value.SetDirection(direction);
            }
        }
 
        public void Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            foreach (KeyValuePair<String, IBackGround> pair in m_ObjectDictionary)
            {
                pair.Value.Update(gameTime);
            }
        }

        public void Draw(Microsoft.Xna.Framework.GameTime gameTime, Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
        {
            foreach(KeyValuePair<String,IBackGround> pair in m_ObjectDictionary)
            {
                pair.Value.Draw(gameTime, spriteBatch);
            }
        }
    }
}
